package day8;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class FileDemo6 {

    public static void main(String[] args) throws IOException {

        String file = "C:\\test.txt";

        File file1 = new File(file);

        Reader r = new FileReader(file);

        Map<String, Integer> map = new HashMap<String, Integer>();

        int len;
        int count = 0;
        while ((len = r.read()) > 0) {
            char c = (char)len;
            //判断
            if (map.containsKey(c + "")) {
                map.put(c + "", map.get(c + "") + 1);
            }else {
                map.put(c + "", 1);
            }
        }
        Set<String> keySet = map.keySet();
        for (String s : keySet) {
            System.out.println("字符:" + s + "出现" + map.get(s) + "次");
        }
    }
}
